package com.zb.zbtcommon.controller;

import com.zb.zbtcommon.dto.ResponseEntity;
import com.zb.zbtcommon.entity.BusinessSchool;
import com.zb.zbtcommon.service.BusinessSchoolService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/zbt/common/businessschool")
public class BusinessSchoolController {

    private Logger logger = LoggerFactory.getLogger(NewsController.class);

    @Autowired
    private BusinessSchoolService businessSchoolService;
    @RequestMapping("/findABusinessByNewsId")
    public ResponseEntity<BusinessSchool> findABusinessByNewsId(String newsid){
        ResponseEntity<BusinessSchool> entity =null;
        try {
            entity = new ResponseEntity<>();
            BusinessSchool business=businessSchoolService.findABusinessByNewsId(newsid);
            if(business!=null){
                entity.setCode(HttpStatus.OK.value());
                entity.setTarget(business);
            }
        } catch (Exception e) {
            logger.error("地址：/zbt/common/businessschool/findABusinessByNewsId-----------------请求参数：newsid"+newsid+"       异常信息"+e.getMessage());
            e.printStackTrace();
            entity.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
            entity.setMessage("根据newID查询BusinessSchool对象数据错误");
        }
        return entity;

    }
}
